// app.js
import {
    colorUI
} from './settings/config';
import {Utils} from './utils/util';
import {
    Token
} from "./utils/token"
import loadServerData from "./settings/photoData";


App({
    colorUI,
    onLaunch() {
        var _this = this;
        var count = 0;
        const waitOnload = function () {
            const o = setInterval(() => {
                count +=1;
                if(count >10){
                    clearInterval(o)
                }
                if (_this.callBack) {
                    _this.callBack();
                    clearInterval(o);
                }
            }, 10);
        }

        // 登录
        Token.getTokenFromServer().then(res => {
            // 登录成功,加载数据
            loadServerData().then(res=>{
                _this.globalData.serverData = res;
                waitOnload();
            });
               
            
        }).catch(err => {
            Utils.showErrorBox(err.msg,'登录失败')
        });

    },
    globalData: { //全局变量
        serverData:undefined
    }

})